#!/bin/sh
# Copyright (C) 2017  Koz Ross <koz.ross@retro-freedom.nz>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# fno-rtti, fno-threadsafe-statics are irrelevant for C, so not bothering

DISABLES="-fno-aggressive-loop-optimizations \
  -fno-asynchronous-unwind-tables \
  -fno-auto-inc-dec \
  -fno-dce \
  -fno-delete-null-pointer-checks \
  -fno-dse \
  -fno-early-inlining \
  -fno-fp-int-builtin-inexact \
  -fno-function-cse \
  -fno-gcse-lm \
  -fno-inline \
  -fno-inline-atomics \
  -fno-ira-hoist-pressure \
  -fno-ira-share-save-slots \
  -fno-ira-share-spill-slots \
  -fno-ivopts \
  -fno-jump-tables \
  -fno-lifetime-dse \
  -fno-peephole \
  -fno-plt \
  -fno-prefetch-loop-arrays \
  -fno-printf-return-value \
  -fno-rename-registers \
  -fno-sched-critical-path-heuristic \
  -fno-sched-dep-count-heuristic \
  -fno-sched-group-heuristic \
  -fno-sched-interblock \
  -fno-sched-last-insn-heuristic \
  -fno-sched-rank-heuristic \
  -fno-sched-spec \
  -fno-sched-spec-insn-heuristic \
  -fno-sched-stalled-insns-dep \
  -fno-schedule-fusion \
  -fno-short-enums \
  -fno-shrink-wrap-separate \
  -fno-split-ivs-in-unroller \
  -fno-ssa-backprop \
  -fno-stdarg-opt \
  -fno-strict-volatile-bitfields \
  -fno-tree-cselim \
  -fno-tree-forwprop \
  -fno-tree-loop-if-convert \
  -fno-tree-loop-im \
  -fno-tree-loop-ivcanon \
  -fno-tree-loop-optimize \
  -fno-tree-phiprop \
  -fno-tree-reassoc \
  -fno-tree-scev-cprop \
  -fno-var-tracking \
  -fno-var-tracking-assignments \
  -fno-web"

#shellcheck disable=SC2086,SC2068
gcc ${DISABLES} $@
